﻿using GPSTracker.Helper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.UI;

namespace GPSTracker.CommonDAL
{
    public class ErrorDAL
    {
        public static void ErrorLog(string erMsg, string erForm, string erFx)
        {
            try
            {
                var CmdSave = new SqlCommand();
                CmdSave.Connection = CommonFx.GetSqlCon();
                CmdSave.CommandType = CommandType.StoredProcedure;
                CmdSave.CommandText = "SP_InsertError";

                CmdSave.Parameters.Add(new SqlParameter("@pErrorMessage", erMsg));
                CmdSave.Parameters.Add(new SqlParameter("@pErrorForm", erForm));
                CmdSave.Parameters.Add(new SqlParameter("@pErrorFx", erFx));

                CmdSave.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(null, typeof(Page), "alertmessage", "javascript:alert('" + Helper.ExceptionHandler.GetErrorMsg(ex) + "');", true);                
            }
        }
    }
}
